package mega.privacy.android.feature.devicecenter.ui.lists

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import mega.privacy.android.shared.original.core.ui.preview.CombinedThemePreviews
import mega.privacy.android.feature.devicecenter.ui.model.BackupDeviceFolderUINode
import mega.privacy.android.feature.devicecenter.ui.model.OwnDeviceUINode
import mega.privacy.android.feature.devicecenter.ui.model.icon.DeviceCenterUINodeIcon
import mega.privacy.android.feature.devicecenter.ui.model.icon.DeviceIconType
import mega.privacy.android.feature.devicecenter.ui.model.icon.FolderIconType
import mega.privacy.android.feature.devicecenter.ui.model.status.DeviceCenterUINodeStatus
import mega.privacy.android.shared.original.core.ui.theme.OriginalTheme

/**
 * A Preview Composable that displays all possible Device and Device Folder Icons
 *
 * @param icon The [DeviceCenterUINodeIcon] generated by the [DeviceCenterUINodeDeviceIconProvider]
 */
@CombinedThemePreviews
@Composable
private fun PreviewDeviceCenterUINodeIconDevice(
    @PreviewParameter(DeviceCenterUINodeDeviceIconProvider::class) icon: DeviceCenterUINodeIcon,
) {
    OriginalTheme(isDark = isSystemInDarkTheme()) {
        DeviceCenterListViewItem(
            uiNode = OwnDeviceUINode(
                id = "1234-5678",
                name = "Device Name",
                icon = icon,
                status = DeviceCenterUINodeStatus.UpToDate,
                folders = emptyList(),
            ),
        )
    }
}

/**
 * A Preview Composable that displays all possible Device and Device Folder Icons
 *
 * @param icon The [DeviceCenterUINodeIcon] generated by the [DeviceCenterUINodeFolderIconProvider]
 */
@CombinedThemePreviews
@Composable
private fun PreviewDeviceCenterUINodeIconFolder(
    @PreviewParameter(DeviceCenterUINodeFolderIconProvider::class) icon: DeviceCenterUINodeIcon,
) {
    OriginalTheme(isDark = isSystemInDarkTheme()) {
        DeviceCenterListViewItem(
            uiNode = BackupDeviceFolderUINode(
                id = "1234-5678",
                name = "Connection Folder Name",
                icon = icon,
                status = DeviceCenterUINodeStatus.UpToDate,
                rootHandle = 1234L,
            ),
        )
    }
}

/**
 * A [PreviewParameterProvider] class that provides the list of Device Icons to be displayed in the Composable preview
 */
internal class DeviceCenterUINodeDeviceIconProvider :
    PreviewParameterProvider<DeviceCenterUINodeIcon> {
    override val values = listOf(
        DeviceIconType.Android,
        DeviceIconType.IOS,
        DeviceIconType.Linux,
        DeviceIconType.Mac,
        DeviceIconType.Mobile,
        DeviceIconType.PC,
        DeviceIconType.Windows,
    ).asSequence()
}

/**
 * A [PreviewParameterProvider] class that provides the list of Folder Icons to be displayed in the Composable preview
 */
internal class DeviceCenterUINodeFolderIconProvider :
    PreviewParameterProvider<DeviceCenterUINodeIcon> {
    override val values = listOf(
        FolderIconType.Backup,
        FolderIconType.CameraUploads,
        FolderIconType.Folder,
        FolderIconType.Sync,
    ).asSequence()
}
